package com.qiuzhi;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Taken3and5digits {

    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        dfs(arr, 0);
        set.forEach(m-> System.out.println(m));
    }

    static Set<String> set = new HashSet<>();

    private static void dfs(int[] arr, int n) {
        if (arr.length == n) {
            set.add(arr[0] + " " + arr[1] + " " + arr[2]);
            return;
        }
        for (int i = n; i < arr.length; i++) {
            int temp = arr[i];
            arr[i] = arr[n];
            arr[n] = temp;
            dfs(arr, n + 1);
            temp = arr[i];
            arr[i] = arr[n];
            arr[n] = temp;
        }
    }
}
